﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace miniCCR
{
    public class Proxy
    {
        public uint _ToComID;
        public uint _ToID;

        public  uint _FromComID;
        public  uint _FromID;


        public Proxy()
        {

        }

        public Proxy(GComponent FromCom, GComponent ToCom)
        {
            _FromID = FromCom._Owner._ID;
            _FromComID = FromCom._ComID;

            _ToID = ToCom._Owner._ID;
            _ToComID = ToCom._ComID;


        }

        void InitOP(Operation op)
        {
            op._FromComID = _FromComID;
            op._FromID = _FromID;

            op._ToID = _ToID;
            op._ToComID = _ToComID;
        }


        public iTask Post(Operation send, Operation wait)
        {
            InitOP(send);

            send._WaitCode = 0;

            if (wait != null)
            {
                InitOP(wait);
            }

            return new iTask(send, wait);

        }


        public iTask Post(Operation send)
        {
            uint t = send._FromComID;
            send._FromComID = send._ToComID ;
            send._ToComID = t;

            t = send._FromID;
            send._FromID = send._ToID;
            send._ToID = t;



            //InitOP(send);


            return new iTask(send, null);
        }

    }



    //public class ReturnProxy : Proxy
    //{
    //    public ReturnProxy(GComponent FromCom, GComponent ToCom)
    //        : base(FromCom, ToCom)
    //    {
    //    }

    //    public override iTask Post(Operation send)
    //    {
    //        return null;
    //    }
    //}



    //public class SendProxy : Proxy
    //{
    //    public SendProxy(GComponent FromCom, GComponent ToCom)
    //        : base(FromCom, ToCom)
    //    {
    //    }

    //    public override iTask Post(Operation send)
    //    {
    //        return null;
    //    }
    //}



}
